2 void pwm_handler(void){
4 static uint8_t cnt_pwm = 0;
6 if (cnt_pwm == 0 ) output_high(PORTB, PWM);
7 if (cnt_pwm == PWM_scale * PWM_MAX / 100 ) output_low(PORTB, PWM);
8 if (cnt_pwm++ == PWM_MAX) cnt_pwm = 0;
12 void pwm_scale_handler( void ){
14 static uint8_t PWM_scale_cnt = 0;
16 if ( PWM_scale_flag && PWM_scale_cnt++ % 32 == 0 ){
17 if ( PWM_scale_target > PWM_scale ) PWM_scale++;
18 else if ( PWM_scale_target < PWM_scale ) PWM_scale--;
19 else if ( PWM_scale_target == PWM_scale ) PWM_scale_flag = false;
21 if ( CIEL8[ PWM_scale ] == 0 ) TCCR0A &=~ (1<<COM0A1); else TCCR0A |= (1<<COM0A1);
22 OCR0A = CIEL8[ PWM_scale ]; // 0..255 with OCIE0A // < 0..100 with pwm_handler